package cate.game.play.skill.brother;

import cp.solution.util.str.Str;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

@NoteClass("兄弟技能选择器")
public abstract class BrotherSkillSelector {

	@NoteField("满足条件后释放的技能")
	protected List<Integer> skills;

	@NoteField("不满足条件时释放的技能")
	protected List<Integer> backUpSkills;

	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		String skillStr = args.get("技能");
		if (StringUtils.isNotBlank(skillStr)) {
			skills = Str.strArr2intList(skillStr.split("#"));
		}
		String backSkillStr = args.get("备用技能");
		if (StringUtils.isNotBlank(backSkillStr)) {
			backUpSkills = Str.strArr2intList(backSkillStr.split("#"));
		}
		parseArgs(args);
	}

	protected abstract void parseArgs(PlayCfgArgs args);


	protected boolean check(SkillActionCtx action) {
		return true;
	}

	public List<Integer> select(SkillActionCtx action) {
		if (check(action)) {
			return skills;
		} else {
			return backUpSkills;
		}
	}
}
